package
        com.zzc.sale.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hos.entity.stock.Medicines;
import com.hos.entity.sys.User;
import com.hos.utils.JwtUtils;
import com.hos.utils.WebUtil;
import com.hos.vo.Result;
import com.zzc.sale.service.MedicinesService;
import com.zzc.sale.vo.MedicinesVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author：xIAO_ZHOU_TX
 * @date：Created in 2023/12/12 9:57
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/sale/api/erp/medicines")
@Api(value = "药品信息维护相关接口", tags = "药品信息维护相关接口")
public class APIMedicinesController {
    @Resource
    private MedicinesService medicinesService;

    @PostMapping("/listMedicinesForPage")
    @ApiOperation(value = "查询表格药品所有信息")
    public Result<Page<Medicines>> selectAllMedicines(@RequestBody MedicinesVo medicinesVo) {
        Page<Medicines> medicinesByCond = medicinesService.findMedicinesByCond(medicinesVo);
        return new Result<>(200, "查询成功", medicinesByCond);
    }

    @PostMapping("/addMedicines")
    @ApiOperation(value = "添加生产药品信息")
    public Result<Integer> addMedicines(Medicines medicines) {
        Integer integer = medicinesService.addMedicines(medicines);
        return new Result<>(200, "添加成功", integer);
    }

    @PutMapping("/updateMedicines")
    @ApiOperation(value = "修改生产药品信息")
    public Result updateMedicines(@RequestBody Medicines medicines) {
        return new Result<>(200, "修改成功", medicinesService.updateMedicines(medicines));
    }

    @PostMapping("/getMedicinesById/{medicinesId}")
    @ApiOperation(value = "根据id查询单个药品信息")
    public Result<Medicines> getMedicinesById(@PathVariable Long medicinesId) {
        Medicines medicines = medicinesService.getMedicinesById(medicinesId);
        return new Result<>(200, "查询成功", medicines);
    }

    @DeleteMapping("/deleteMedicinesByIds/{ids}")
    @ApiOperation(value = "根据id删除药品信息")
    public Result<Integer> deleteMedicinesByIds(@PathVariable List<Long> ids) {
        Integer integer = medicinesService.deleteMedicinesByIds(ids);
        return new Result<>(200, "删除成功", integer);

    }

    @PostMapping("/updateMedicinesStorage/{medicinesId}/{medicinesStockNum}")
    @ApiOperation(value = "调整药品库存")
    public Result updateMedicinesStorage(@PathVariable Long medicinesId, @PathVariable Integer medicinesStockNum) {
        return new Result<>(200, "修改成功", medicinesService.updateMedicinesStorage(medicinesId, medicinesStockNum));
    }


}